<template>
    <div>
        <div class="head">
            <span class="iconfont icon-arrow-left-bold" @click="gotoUp"></span>
            <div class="title">我的消息</div>
        </div>
        <div class="content">
            <div class="item" v-for="item in arr" :key="item.id">
                <div class="name">{{ item.data.message }}</div>
                <div class="time">{{ item.created_at | timeago }}</div>
            </div>
        </div>
        <div class="drop">已经到底了</div>
    </div>
</template>

<script>
export default {
    data() {
        return {
            arr: [],
        };
    },
    methods: {
        gotoUp() {
            this.$router.push({
                path: "/user",
                query: {},
            });
        },
    },
    async created() {
        let res = await this.$request.get("/api/v2/member/messages", {
            params: {
                page: 1,
                page_size: 20,
            },
        });
        this.arr = res.data.data;
    },
};
</script>

<style lang="less" scoped>
.head {
    position: fixed;
    top: 0;
    width: 100%;
    height: 50px;
    background-color: #fff;
    z-index: 100;
    padding-left: 15px;
    padding-right: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid #f1f2f6;
    span {
        font-size: 19px;
        position: absolute;
        top: 50%;
        margin-top: -10px;
        left: 4%;
    }
    .title {
        flex: 1;
        font-size: 17px;
        font-weight: 500;
        text-align: center;
        color: #333;
        line-height: 22px;
        overflow: hidden;
    }
}
.content {
    padding-top: 50px;
    background: #f6f6f6;
    .item {
        width: 100%;
        padding: 10px 15px;
        background-color: #fff;
        border-bottom: 1px solid rgba(0, 0, 0, 0.05);
        height: 66px;
        .name {
            width: 100%;
            font-size: 14px;
            line-height: 20px;
            margin-bottom: 10px;
            word-break: break-all;
            color: rgba(0, 0, 0, 0.3);
        }
        .time {
            width: 100%;
            height: auto;
            float: left;
            font-size: 10px;
            color: rgba(0, 0, 0, 0.3);
        }
    }
}
.drop {
    display: inline-block;
    width: 100%;
    text-align: center;
    color: #ccc;
    font-size: 14px;
    margin-top: 30px;
    margin-bottom: 30px;
}
</style>
